package com.golang.api.config;

import com.golang.api.interceptor.TokenInterceptor;
import com.golang.api.interceptor.SignInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;


@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    private SignInterceptor signInterceptor;
    @Resource
    private TokenInterceptor tokenInterceptor;

    /**
     * 注册拦截器
     *
     * @param registry registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(tokenInterceptor)
                .addPathPatterns("")
                .excludePathPatterns("/api/user/login");
        registry.addInterceptor(signInterceptor)
                .addPathPatterns("")
                .excludePathPatterns("/api/user/login");
    }

}
